<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ page import="java.util.*" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="java.sql.Statement" %>



<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=uft-8">
<title>学生人数</title>
<style type="text/css">td,th{ padding:5px;}</style>
</head>
<body>
<%
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/jsp";
String username = "root";
String password = "root";
Connection conn = DriverManager.getConnection(url,username,password);
Statement stmt = conn.createStatement();
String sql= "select count(*) as a from tb_student";
ResultSet rs= stmt.executeQuery(sql);
String str_a = "";
if(rs.next()){
	str_a = rs.getString("a");
}
%>
<h2>学生人数：<%=str_a %></h2>
</body>
</html>